package jzqb.dao.impl;

import cnki.tpi.kbatis.sqlsession.SqlSession;
import cnki.tpi.kbatis.utils.DataSourceUtil;
import jzqb.bo.SubscriptBo;
import jzqb.bo.SubscriptDataBo;
import jzqb.dao.SubscriptDao;
import org.springframework.stereotype.Repository;

import java.util.List;
/**
 * 自用库数据层实现类
 */
@Repository
public class SubscriptDaoImpl implements SubscriptDao {

    @Override
    public Boolean insertSubscript(SubscriptBo subscriptBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.SubscriptDao.insertSubscript";
        return sqlSession.executeInsert(statementId, subscriptBo);
    }

    @Override
    public SubscriptBo selectSubscript(SubscriptBo subscriptBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.SubscriptDao.selectSubscript";
        return sqlSession.selectOne(statementId, subscriptBo,false);
    }

    @Override
    public List<SubscriptBo> getAlreadySubscript(SubscriptBo subscriptBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.SubscriptDao.getAlreadySubscript";
        return sqlSession.selectList(statementId, subscriptBo,false);
    }

    @Override
    public Boolean deleteSubscriptById(SubscriptBo subscriptBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.SubscriptDao.deleteSubscriptById";
        return sqlSession.executeDelete(statementId, subscriptBo);
    }

    @Override
    public SubscriptBo getSubScriptBoByCondition(SubscriptDataBo subscriptDataBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.SubscriptDao.getSubScriptBoByCondition";
        return sqlSession.selectOne(statementId, subscriptDataBo,false);
    }

    @Override
    public SubscriptBo getSubscriptById(SubscriptBo subscriptBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.SubscriptDao.getSubscriptById";
        return sqlSession.selectOne(statementId, subscriptBo,false);
    }
}
